package May22ch19ex1;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class MyMain {
	public static void main(String[] args) throws NoSuchFieldException,
			SecurityException, IllegalArgumentException, IllegalAccessException {
		Person person = new Person();
		person.setName("Tomek");

		Field[] declaredFields = Person.class.getDeclaredFields();
		for (Field field : declaredFields) {
			System.out.println(field);
		}

		Field field = Person.class.getDeclaredField("name");
		field.setAccessible(true);
		field.set(person, "wcalenieTomek");
		Method[] declaredMethods = Person.class.getDeclaredMethods();
		for (Method method : declaredMethods) {
			System.out.println(method);
		}
		System.out.println("My name is " + person.getName());
	}
}
